home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-09-02 | 3.7 KB | 94 lines | [TEXT/CCL2] |
- ;;; graphics-interface.lisp
- ;;;
- ;;; this is where the parser and the graphics package are integrated.
-
- ;;; avm-tree-object is a subclass of tree-object that can have avm-objects associated
- ;;; with each node
-
- (defclass avm-tree-object (tree-object)
- ((avs :reader avs :initform nil :initarg :avs)))
-
- (defmethod selectable-p ((tree avm-tree-object))
- (avs tree))
-
- (defmethod select ((tree avm-tree-object))
- (call-next-method)
- (let ((avs (avs tree)))
- (when avs
- (drawAvm (avs-to-avm avs)))))
-
-
- (defun avs-to-avm (avs)
- (let ((copy-generation (list '*avm-copy*))
- (index-count 0))
- (labels ((doNode (avs-node)
- (let ((node (follow-pointers avs-node)))
- (if (constant-p node)
- (make-instance 'string-object :string node)
- (if (eq (avnode-generation node) copy-generation)
- (let ((avm (avnode-newcontents node)))
- (when (null (index avm))
- (setf (index avm)
- (make-instance 'index-object
- :string (incf index-count))))
- (make-instance 'index-object
- :string (display-string (index avm))))
-
- (let ((contents (avnode-contents node))
- (new-node (make-instance 'avm-object)))
- (setf (avnode-generation node) copy-generation)
- (setf (avnode-newcontents node) new-node)
- (set-avm-pairs new-node
- (mapcar #'(lambda (avp)
- (make-avm-pair (avpair-att avp)
- (doNode (avpair-val avp))))
- contents))
- new-node))))))
- (doNode avs))))
-
-
- (defun InstToTreeGraphic (inst)
- "builds a set of click-trees"
- (labels ((label (i)
- (let ((c (if *cat-prefix*
- (avn-att-val (inst-cat i) *cat-prefix*)
- (inst-cat i))))
- (if c
- (avs-to-avm c)
- (make-instance 'string-object :string "")))))
- (if (inst-p inst)
- (make-instance 'avm-tree-object
- :root (label inst)
- :avs (if *val-prefix*
- (make-att-val (inst-cat inst) *val-prefix*)
- (inst-cat inst))
- :subtrees (mapcar #'InstToTreeGraphic
- (inst-daughters inst)))
- (make-instance 'string-object :string inst))))
-
-
- (defun DrawAvm (avs &key selectable-p)
- "Draws a tree in its own tree window"
- (if (listp avs)
- (setf avs (list-to-avs avs)))
- (let ((front-window (front-window)))
- (unless (and (typep *avm-window* 'graphic-window)
- (wptr *avm-window*))
- (setf *avm-window* (make-instance 'graphic-window
- :window-title "AV Window"
- :view-size #@(200 200)
- :view-position #@(200 40))))
- (draw-object *avm-window* avs :selectable-p selectable-p)
- (window-show *avm-window*)
- (window-select *avm-window*)
- (window-select front-window)))
-
-
- (defun Display (n)
- (if (<= 1 n (length *results*))
- (let ((e (elt *results* (- n 1))))
- (drawTree (InstToTreeGraphic e) :selectable-p T)
- (drawAvm (avs-to-avm (if *val-prefix*
- (make-att-val (inst-cat e) *val-prefix*)
- (inst-cat e)))))
- (format t "Sorry, there are only ~s results~%" (length *results*))))